﻿@using StackExchange.Opserver.Data.Redis
@using StackExchange.Opserver.Views.Redis
@model DashboardModel
@{
    Layout = "~/Views/Shared/Master.cshtml";
    this.SetPageTitle("Redis Dashboard");
    this.SetTopNodes(RedisInstance.AllInstances, "Redis Servers", Model.CurrentInstance);
}
@helper TabLink(RedisViews view, string href, string name, bool includeParams = true)
{
    <a class="@(Model.View == view ? "selected" : "")" href="@href@(includeParams && Model.CurrentInstance != null ? string.Format("?node={0}:{1}", Model.CurrentInstance.Host, Model.CurrentInstance.Port) : "")">@name</a>
}
@section head {
    <script>
        $(function() {
            Status.Dashboard.init({ refresh: @(Model.Refresh ? 5 : 0) });
            Status.Redis.init({ node: '@(Model.CurrentInstance != null ? Model.CurrentInstance.Host : "")', port: '@(Model.CurrentInstance != null ? Model.CurrentInstance.Port.ToString() : "")' });
        });
    </script>
}
    <div class="tabs sub-tabs">
        <div class="tabs-links">
            @TabLink(RedisViews.All, "/redis", "all servers", false)
            @TabLink(RedisViews.Instance, "/redis/instance", "instance")
        </div>
    </div>
<div class="dashboard-list">
    @if (Model.View == RedisViews.Instance && Model.CurrentInstance == null)
    {
        @Html.Partial("Instance.Selector")
    }
    @RenderBody()
</div>